-- By ScatmanJosh --

-- Variables --
XEN = XEN or {}
XEN.Ownerships = {}
local ENTITY = FindMetaTable( "Entity" )
ENTITY.Owner = nil

-- Functions --
function ENTITY:GetPlayerOwner( )
	local ply = self.Owner
	if not IsValid( ply ) or not ply:IsPlayer() then return false end
	return ply
end

function ENTITY:SetPlayerOwner( ply ) --PLY:PLAYER
	if not IsValid( ply ) then return false end
	self.Owner = ply
	return true
end

function XEN.Ownerships.GetPlayerOwnedEnts( ply ) --PLY:PLAYER
	local owned = {}
	for k,v in pairs( ents.GetAll() ) do
		if v:GetPlayerOwner() == ply then
			table.insert( owned, v )
		end
	end
	return owned, #owned
end